import request from '@/utils/request'
import type { ResApi, RoleInfo, AddRoleType, RoleListType } from '@/types/role'

// 角色列表请求
export const getRoleListApi = (params: RoleListType) => {
  return request<ResApi<RoleInfo[]>>({
    method: 'get',
    url: '/role/index',
    params,
  })
}
// 2.封装新增角色接口
export const addRoleApi = (data: AddRoleType) => {
  return request<ResApi<null>>({
    method: 'post',
    url: '/role/create',
    data,
  })
}

// 删除角色
export const RemoveRoleApi = (params: RoleInfo) => {
  return request<ResApi<null>>({
    method: 'delete', //相对于get参数是拼接到url的后面的
    url: '/role/delete',
    params,
  })
}

// 更新用户
export const updateRoleApi = (data: AddRoleType) => {
  return request<ResApi<null>>({
    method: 'put', //相当于get 参数是拼接到url的后面的
    url: '/role/update',
    data,
  })
}
// 封装给角色分配权限接口
export const assignRoleAuthApi = (data: any) => {
  return request({
    method: 'put',
    url: '/role/assign',
    data,
  })
}
